<?php

namespace backend\models;
use yii\behaviors\TimestampBehavior;
use Yii;

/**
 * This is the model class for table "{{%jjr_user_project}}".
 *
 * @property string $id
 * @property int $jjr_user_id 用户ID
 * @property int $jjr_project_id 项目ID
 * @property string $client_gender 客户性别
 * @property string $client_real_name 客户姓名
 * @property string $client_mobile 客户手机
 * @property string $remark 备注
 * @property string $process 项目进度
 * @property string $process_remark 项目备注
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 * @property string $status 状态
 * @property string $adviser 置业顾问
 * @property string $adviser_mobile 置业顾问电话
 */
class JjrUserProject extends \common\core\BaseActiveRecord
{
    /*报备->到访接待->认筹认购->签约->付款  不是自由哦经纪人课忽略第一步*/
    const PROCESS_SIGN_UP = '1';
    const  PROCESS_RECEPTION = '2';
    const  PROCESS_CONFIRM = '3';
    const  PROCESS_CONTRACT = '4';
    const  PROCESS_PAY = '5';

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%jjr_user_project}}';
    }
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    # 创建之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
                    # 修改之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['update_time']
                ],
                #设置默认值
                'value' =>date('Y-m-d H:i:s')
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['jjr_user_id', 'jjr_project_id', 'client_gender', 'client_real_name', 'client_mobile'], 'required'],
            [['jjr_user_id', 'jjr_project_id','status'], 'integer'],
            [['create_time', 'update_time'], 'safe'],
            [['client_gender', 'client_real_name', 'process', 'process_remark','adviser'], 'string', 'max' => 255],
            [['client_mobile','adviser_mobile'], 'string', 'max' => 11],
            [['remark'], 'string', 'max' => 500],
            ['client_mobile','match','pattern'=>'/^[1][34578][0-9]{9}$/'],
            ['adviser_mobile','match','pattern'=>'/^[1][34578][0-9]{9}$/'],
            [['jjr_user_id', 'jjr_project_id','client_mobile'], 'unique', 'targetAttribute' => ['jjr_user_id', 'jjr_project_id','client_mobile']]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'jjr_user_id' => '用户ID',
            'jjr_project_id' => '项目ID',
            'client_gender' => '客户性别',
            'client_real_name' => '客户姓名',
            'client_mobile' => '客户手机',
            'remark' => '备注',
            'process' => '项目进度',
            'process_remark' => '项目备注',
            'create_time' => '创建时间',
            'update_time' => '更新时间',
            'status' => '状态',
            'adviser'=>'置业顾问',
            'adviser_mobile'=>'置业顾问电话',
        ];
    }
}
